/*
 * SalaBus.h
 *
 */

#ifndef SALABUS_H_
#define SALABUS_H_

#include "APICommon.h"
#include "Persona.h"
#include "IPC/SharedMemory2.h"
#include "IPC/Semaphore.h"
#include "IPC/MessageQueue2.h"
#include "Middleware/MiddlewareMessages.h"
#include "Middleware/NonBlockingMessageQueue.h"

namespace API {

class SalaBus
{
public:
	typedef enum {ATENDER_PERSONAS=0, ATENDER_BUS, CLIENT} salaTypeEnum;
public:
	SalaBus(salaTypeEnum type);
	virtual ~SalaBus();

	void init();

	void destroy();

	BusId esperarBus(SalaId nSala,Persona &persona, int &error);

	Persona getPasajero(SalaId nSala);

	bool tienePasajeros(SalaId nSala);

	void indicarBusDestino(BusId busId,Persona &persona);

	void run(SalaId nSala, BusId nBus);

private:
	NonBlockingMessageQueue<waitingBusRequest> m_nonBlockingQueue;
	MessageQueue2<entryWaitRoomRequest> m_requests;
	MessageQueue2<entryWaitRoomReply> m_reply;
	bool m_doRun;
};

}

#endif /* SALABUS_H_ */
